﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace C4F.DevKit.WebServicesDemo.UserControls
{
    public partial class MySpaceControl : UserControl
    {
        public MySpaceControl()
        {
            InitializeComponent();
        }

        private void GoButton_Click(object sender, EventArgs e)
        {
            try
            {
                MySpaceResults = MySpaceService.SearchFriends_DS(SearchText.Text);
                MySpaceGrid.DataSource = MySpaceResults.MySpaceUser;
            }
            catch (System.Net.WebException ex)
            {
                StreamReader streamReader = new StreamReader(ex.Response.GetResponseStream());
                string responseData = streamReader.ReadToEnd();
                streamReader.Close();
                MessageBox.Show(responseData);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

        private void MySpaceGrid_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewSelectedCellCollection Cells = MySpaceGrid.SelectedCells;
            if (Cells[0] is System.Windows.Forms.DataGridViewLinkCell)
            {
                DataGridViewLinkCell LinkCell = (DataGridViewLinkCell)Cells[0];
                DemoBrowserImage ImageForm = new DemoBrowserImage((string)LinkCell.Value);
                ImageForm.Show();
            }     
        }

       
    }
}
